-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Feat/2325/unclosed parentheses frequently appear during editing #3997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/2325/unclosed parentheses frequently appear during editing #3997
Conversation
|
I have seen the closed PR #3411 which extracts the single apply diff into its own function, i think that could be a good addition for reducing complexity too. |
54a09ad to
70203d0
Compare
70203d0 to
b6d022a
Compare
b6d022a to
98b06ce
Compare
|
@Ruakij is attempting to deploy a commit to the Roo Code Team on Vercel. A member of the Team first needs to authorize it. |
98b06ce to
7af69b8
Compare
…ristics in applyDiff method
… processing every replacement-block
7af69b8 to
42879fb
Compare
|
Hey @Ruakij, thanks for working on this! I've been looking through the changes and I appreciate the modular approach you've taken. I'm a bit concerned though - this feels like quite a complex solution for something that mainly affects DeepSeek models (DeepSeek R1 to be more specific). The engine adds processing to every search/replace operation, and I worry it might interfere with cases where someone actually wants to duplicate similar code patterns. Since the root issue seems to be that certain LLMs include existing closing braces in their replacements, what do you think about trying something simpler first? Maybe we could improve the prompts for those specific models, or add a quick check that warns when a replacement would create syntax errors? I'm curious if you considered any lighter-weight approaches before going with the engine solution? Would love to hear your thoughts on this! |
|
I think there is always a danger when trying to fix issues some LLMs might have or how their behaviour is. I have had this replacement issue with Sonnet models multiple times now too. My approach is pretty primitive, but should cover most scenarios, as long as replacement lines arent similar on purpose. Not 100% sure how to detect that reliably. For structured languages with grammar-rules we can parse, at least we can detect if either the LLM or our fix made a mistake, so if we really want to keep the fix broad but reduce errors, the ideal approach would be to parse the result first and check if syntax errors were introduced at the edges. So for now, maybe keeping the SuperfluousDuplicatedLineEngine is okay, but adding some checks so we dont accidentally touch stuff we didnt want "fixed". e.g. We only consider lines "similar" if they have at least 3 characters (including spaces), but we wont apply any fixes when we find more than 2 similar lines. (or % of output) |
|
@Ruakij Checking every I'll close this PR for now but that doesn't mean I am not open to discussing this further, please let me know what you think! |
Related GitHub Issue
Closes: #2325
Description
This PR adds protection against LLM-generated code edits that incorrectly duplicate closing braces and lines in MultiSearchReplace or ApplyDiff Tool.
e.g. when LLMs append methods to files using search/replace operations, they often include existing closing braces in the replacement content, leading to syntax errors from duplicated braces. The new system detects these patterns and automatically adjusts the replacement scope to prevent duplicate lines.
Key implementation details:
Test Procedure
Type of Change
srcor test files.Pre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
I have added a Modular approach to for such fixes to MultiSearchReplace for future issues
Some of the existing code could also be refactored into these Modules like Unescaping, Stripping Line numbers or other Error-checking.
I chose this approach because the file and function already is very big and complex.
If this is unwanted i could simply add my modification as function at the bottom instead.
Special consideration should be taken when testing the changes to make sure they dont break normal diffs on accident.
Get in Touch
Discord:
ruakijImportant
Introduces
SuperfluousDuplicatedLineEngineto handle duplicated lines in diffs, with integration and tests inmulti-search-replace.ts.SuperfluousDuplicatedLineEngineto detect and adjust for duplicated lines inmulti-search-replace.ts.applyDiff()inmulti-search-replace.tsto prevent duplicate lines during replacements.multi-search-replace.test.tsfor scenarios like appending content without duplicating braces or lines, handling line similarity, and edge cases.applyDiff()to useSearchReplaceContextfor better context management.This description was created by
for 54a09adcd34cbc6882c93edcc6093c855d13996d. You can customize this summary. It will automatically update as commits are pushed.